/*
Sam Snyder
CS362
Assignment 3 part 1,4
unittest4.c

(20 points) Write unit tests for four functions (not card implementations or cardEffect) in dominion.c. Check these tests in as unittest1.c, unittest2.c, unittest3.c, and unittest4.c. (for example, you can create a test for updateCoins() method)

This is a test of the function endTurn
*-----------------------------------------------------------------------
 * Include the following lines in your makefile:
 *
 * unittest4: unittest4.c dominion.o rngs.o
 *      gcc -o unittest4 -g  unittest4.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include <math.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

 int main() {
 	int i,j,l, r;
 	struct gameState G;
 	int k[10] = {curse, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
 	if (NOISY_TEST == 1)
 		printf("Testing endTurn function\n\n");

 	for (i=2; i <= MAX_PLAYERS; i++){
 		r = initializeGame(i, k, 1, &G);
 		if (NOISY_TEST == 1)
 			printf("\tTesting %d player game\n", i);
 		for(j=0; j< i; j++){
 			printf("%d\n", j);
 			//turn has advanced?
  			assert(whoseTurn(&G) == j);

 			//player j has 5 cards in hand
 			assert(G.handCount[j] ==5);

 			// other players have no cards
  			if(j < i-1)
 				assert(G.handCount[j+1] == 0); 
 			else
 				assert(G.handCount[0] ==0); 
 			endTurn(&G);
 		}
 		assert(whoseTurn(&G) == 0);
 	}
 	if (NOISY_TEST == 1)
 		printf("Tests passed");
 	return 0;
 }